using System.Net;

namespace ThingsGateway.Foundation.Rpc.TouchRpc
{
    internal class UdpRpcActor : RpcActor
    {
        private readonly UdpSessionBase m_udpSession;
        private readonly EndPoint m_endPoint;

        public int Tick;

        public UdpRpcActor(UdpSessionBase udpSession, EndPoint endPoint, ILog logger) : base(false)
        {
            OutputSend = RpcActorSend;
            m_udpSession = udpSession;
            m_endPoint = endPoint;
            Logger = logger;
        }

        private void RpcActorSend(RpcActor actor, ArraySegment<byte>[] transferBytes)
        {
            m_udpSession.Send(m_endPoint, transferBytes);
        }
    }
}